package com.rayc.mall.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rayc.mall.api.dto.OrderItemDTO;
import com.rayc.mall.item.domain.po.Item;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

/**
 * @Author: Ray-C
 * @CreateTime: 2025-03-23
 * @Description: 商品mapper
 * @Version: 1.0
 */
@Mapper
public interface ItemMapper extends BaseMapper<Item> {

    @Update("UPDATE item SET stock = stock - #{num}, sold = sold + #{num}, update_time = now() WHERE id = #{itemId}")
    void updateStockAndSold(OrderItemDTO orderDetail);
}
